export default {
    namespaced: true,
    state: {
        // 微信签名地址 兼容ios和安卓签名失败
        // iOS在页面加载时只需签名一次且需要记录第一次的地址 后续签名都用该地址来签名
        signUrl: ''
    },
    mutations: {
        setSignUrl (state, to) {
            let origin = window.location.origin
            let path = process.env.VUE_APP_PROJECT_CONTEXT
            let url = `${origin}${path}${to.fullPath}`
            // ios wkwebview 并且 第一次进入塞值
            if (window.__wxjs_is_wkwebview) {
                url = state.signUrl || window.location.href.split('#')[0]
            }
            state.signUrl = url
        },
        clearSignUrl (state) {
            state.signUrl = ''
        }
    }
}
